//
// Created by xueke on 2021/11/8.
//

#ifndef COMBINE_QTPROGRESS_ARIA2__MYWIDGET_H_
#define COMBINE_QTPROGRESS_ARIA2__MYWIDGET_H_
#include <QWidget>
#include <QPushButton>
#include <QProgressBar>
#include <QLineEdit>
#include <QLabel>
#include <aria2/aria2.h>
#include <QThread>
#include <QObject>
#include <QStatusBar>
#include <QList>
#include <QCloseEvent>
class downloadWork:public QObject{
Q_OBJECT
 public slots :
  void Download(const QString & url);
  void shutdown();
signals:
  void resultReady(const std::vector<int64_t>&);
 private:
  static int downloadEventCallback(aria2::Session* session, aria2::DownloadEvent event,
										  aria2::A2Gid gid, void* userData);
  aria2::Session *session;
};


class myWidget : public QWidget {
 Q_OBJECT
 public:
  myWidget();
 ~myWidget();
  // 私有成员函数
 private:
  void initFace();
  //槽函数
 public slots :
  void updateProgress(const std::vector<int64_t>&);

 private slots:
  void startCheck();
  bool cancelDownload();

signals :
  void goDownload(const QString &);
void shutdownSession();

  //界面元素
 private:
  QLineEdit *lineLink;
  QProgressBar *progressBar;
  QPushButton *startButton;
  QPushButton *cancelButton;
  //功能变量
 private:
  void closeEvent(QCloseEvent *event);
  QThread workerThread;
};

#endif //COMBINE_QTPROGRESS_ARIA2__MYWIDGET_H_
